class Teacher < Searchable

  set_table_name "docente"

  belongs_to :person, :foreign_key => "pessoa"


  def self.search(search,page)
    if search.blank?
      paginate :page => page,
        :joins => "join pessoa as person on docente.pessoa = person.id",
        :per_page => 8
    else
      paginate :page => page,
        :conditions => ['person.nome like ?', "%#{search}%"],
        :joins => "join pessoa as person on docente.pessoa = person.id",
        :per_page => 8
    end
  end


  def to_s
    self.person.nome
  end

  def cpf
    self.person.cpf
  end

  def siape
    self.person.siape
  end

  def nome
    self.person.nome
  end


end
